﻿{%extends "admin/base.html"%}
{% load i18n %}

{%block content%}
<div class="wrap">
	<h2 class="title1">{% if id %}{% trans "Edit link" %}{% else %}{% trans "Add link" %}{% endif %}</h2>
	{% if messages %}
	<ul class="messages">
		{% for message in messages %}
		<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
		{% endfor %}
	</ul>
	{% endif %}
	<div id="col-container">
		<div id="col-left">
			<h3>{% if id %}{% trans 'Edit link' %}{% else %}{% trans 'Add link' %}{% endif %}</h3>
			<form name="addcat" method="post" action="{{ blog.get_admin_add_link_url }}" class="full-width">
				{{ linkform.id }}
				<div class="form-field form-required">
					<p>{{ linkform.title.label_tag }}<span class="red">*</span></p>
					<p {% if linkform.title.errors %}class="error"{% endif %}>
						{{ linkform.title }}</p>
				    <p>
				    	{% if linkform.title.errors %}{{ linkform.title.errors }}
				    	{% else %}<span class="help_text">e.g: Yang Wanjun's blog</span>{% endif %}
				    </p>
				</div>
				<div class="form-field">
				    <p>{{ linkform.link_url.label_tag }}<span class="red">*</span></p>
					<p {% if linkform.link_url.errors %}class="error"{% endif %}>
						{{ linkform.link_url }}</p>
				    <p>{% if linkform.link_url.errors %}{{ linkform.link_url.errors }}
				    	{% else %}<span class="help_text">e.g: http://www.iyouf.info/ </span>{% endif %}
				    </p>
				</div>
				<div class="form-field">
				    <p>{{ linkform.description.label_tag }}</p>
					<p {% if linkform.description.errors %}class="error"{% endif %}>
						{{ linkform.description }}</p>
				    <p><span class="help_text">
				    	{% trans "Show the description when cursor on the link, or under the link" %}
				    	</span></p>
				</div>
				<p><input class="button" name="submit" 
					value="{% if id %}{% trans 'Edit link' %}{% else %}{% trans 'Add link' %}{% endif %}" 
					type="submit"></p>
			</form>
		</div>
		<div id="col-right">
			<form id="posts-filter" action="{{ blog.get_admin_delete_links_url }}" method="post">
				<div class="tablenav">
					<div class="alignleft">
						<select name="action">
							<option value="" selected="selected">{% trans "Batch" %}</option>
							<option value="delete">{% trans "Delete" %}</option>
						</select>
						<input value="{%trans 'Apply' %}" name="doaction" class="submit button" type="submit">
					</div>
					<br class="clear">
				</div>
				<div class="clear"></div>
				<table class="list" cellspacing="0">
					<thead>
						<tr>
							<th class="check-column" style="">
								<input type="checkbox"  onclick="$('input[name=checks]').attr('checked',this.checked);">
							</th>
							<th>{% trans "Link name" %}</th>
							<th>{% trans "URL" %}</th>
							<th>{% trans "Link description" %}</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th scope="col" class="manage-column column-cb check-column" style="">
								<input type="checkbox"  onclick="$('input[name=checks]').attr('checked',this.checked);">
							</th>
							<th>{% trans "Link name" %}</th>
							<th>{% trans "URL" %}</th>
							<th>{% trans "Link description" %}</th>
						</tr>
					</tfoot>
					<tbody>
						{% if links.object_list %}
						{%for link in links.object_list%}
						<tr>
							<th class="check-column"> 
								<input name="checks" value="{{ link.id }}" type="checkbox"></th>
							<td>
								<strong>
									<a href="{{ link.get_admin_edit_link_url }}" 
										title="{% trans 'Edit' %} &quot;{{ link.title }}&quot;">
										{{ link.title }}</a>
								</strong>
							</td>
							<td class="slug column-slug">
							<a href="{{ link.link_url }}" 
								title=" &quot;{{ link.title }}&quot;" target="_blank">{{ link.link_url }}</a>
							</td>
							<td>{{ link.description }}</td>
						</tr>
						{%endfor%}
						{%else%}
						<tr>
							<td colspan="4" align="center" style="font-size: 16px;">{% trans "No links" %}</td>
						</tr>
						{%endif%}
					</tbody>
				</table>
				<br class="clear">
			</form>
		</div>
	</div>
</div>
{%endblock%}